<?php

namespace App\Model\Task;

use App\Model\Model;
use Hyperf\Database\Model\SoftDeletes;
use Yj\Model\ImageTrait;
use Yj\Model\UserTrait;

/**
 * @property integer $id
 * @property boolean $types
 * @property integer $update_time
 * @property integer $create_time
 * @property integer $delete_time
 * @property integer $image_id
 * @property text $reason
 * @property integer $userid
 * @property integer $task_id
 * @property integer $task_user_id
 * @property string $message
 * @property integer $status
 */
class TaskReport extends Model
{
    use SoftDeletes;
    use ImageTrait;
    use UserTrait;

    /**
     * The table associated with the model.
     * 
     * @var string
     */
    protected $table = 'task_report';

    protected $appends = [
        'create_time_format',
        'status_format',
    ];

    protected $fillable = [
        'types',
        'update_time',
        'create_time',
        'delete_time',
        'image_id',
        'reason',
        'userid',
        'task_id',
        'task_user_id',
        'message',
        'status',
    ];

    public function getCreateTimeFormatAttribute(){
        return $this->checkAttributes('create_time',function($value){
                return date('Y-m-d H:i:s',$value);
        });
    }

    public function getStatusFormatAttribute(){
        return $this->checkAttributes('status',function($value){
            return ['-1'=>'审批拒绝','0'=>'审核中','1'=>'审核通过'];
        });
    }

    public function Task(){
        return $this->hasOne(Task::class,'id','task_id');
    }

}
